Repository navigation
feat(canvas): draw NativeScript views into a canvas on Linux - #256
Merged
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
triniwiz
force-pushed
the
feat/html-in-canvas-linux
branch
3 times, most recently
from
November 18, 2026 15:34
e952613 to
7fbbaaf
Compare
HTML-in-Canvas on GTK 4. A content="drawable" canvas holds each child in a slot the canvas widget allocates but never draws: the slot is placed with the transform the child was last drawn with and clipped to the drawn part, so GTK's own picking sends input where the view appears. The canvas snapshots its children into a scratch snapshot to keep their render nodes current; a GtkWidgetPaintable per drawable view reports when that node changes, and the window's GSK renderer renders it into the snapshot. The per-frame work is native (NSCDrawableHost in canvas-napi): JS makes one update() call a frame and no GTK calls. Geometry is sent as a Float64Array, and only when it changed. A press on a hosted view no longer moves focus to the canvas. Node-API canvases now measure their children at the canvas width and stack them, as on iOS. The htmlincanvas spec suite runs on Linux, with a new test that a source rect limits hit testing to the drawn part.
triniwiz
force-pushed
the
feat/html-in-canvas-linux
branch
from
November 18, 2026 15:35
7fbbaaf to
3f64be2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Includes #254 and #255: merge those first.
HTML-in-Canvas on NativeScript Linux. A
content="drawable"canvas now hosts its children on GTK 4, anddrawElementImage,texElementSubImage2D,drawElementImageToTexture,paintevents,captureElementImageand element geometry work as on iOS and Android.Change
NSCDrawableHost(canvas-napi,host/linux/drawable.rs)NSCDrawableSlotand allocates it, but never draws it. A slot is allocated with the transform the child was last drawn with and sized to the drawn part (canvasClip), with overflow hidden. GTK's own picking therefore sends input to where the view appears and stops at the clip. A child with no geometry is allocated outside the canvas.GtkWidgetPaintableper drawable view reports when that node changes.update()call, which returns the changed views and their sizes. It makes no GTK calls of its own. Geometry is passed as aFloat64Arrayand only when it changed. A press on a hosted view no longer moves focus to the canvas.Shared Node-API canvas: children are measured at the canvas width and stacked, as on iOS (
napi-host.ts).The
htmlincanvasspec suite now runs on Linux, with GTK picking checks for the hit-testing tests and a new test that a source rect limits hit testing to the drawn part.Verified
Pop!_OS 24.04, GTK 4.14, COSMIC Wayland, Mesa (Intel Iris Xe),
apps/demo-linuxwith this branch'scanvasnative.node:htmlincanvas25/25 on three runs, including WebGPU on a real adapter.2d182/182,lifecycle14/14,canvassource18/18,webgl96/96,offscreen64/64.drawElementImageevery frame: the drawable tick averages 0.07 ms a frame idle (0.16 ms max), and 0.33 ms (2.6 ms max) while the form changes ten times a second, with 29paintevents for 30 changes (one frame can carry two).Hit testing follows the geometry of the canvas's own children only: a drawable view nested deeper gets input through its top-level ancestor's geometry.